<!DOCTYPE html>
<html lang="zh">
<#
 include "head.html";
 #>
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <#
     include "lefter.html";
     #>
    <!--End 左侧导航-->
    <!--头部信息-->
    <#
     include "header.html";
     #>
    <!--End 头部信息-->
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-header">
                <h4>GITHUB登陆</h4>
              </div>
              <div class="card-body">
                <form method="post" action="#!" class="site-form">
                  <div class="form-group">
                    <label for="newpwd">应用账号</label>
                    <input type="text" class="form-control" name="clientId" id="clientId" value="${githubControl.clientId}">
                  </div>
                  <div class="form-group">
                    <label for="confirmpwd">应用密钥</label>
                    <#
                     if ($isSuper == "T")
                     #>
                    <input type="text" class="form-control" name="clientSecret" id="clientSecret" value="${githubControl.clientSecret}">
                    <#
                     else
                     #>
                    <input type="text" class="form-control" name="clientSecret" id="clientSecret" value="****************************************" disabled>
                    <#
                     fi;
                     #>
                  </div>
                  <div class="form-group">
                    <label for="confirmpwd">回调地址（如：http://域名/oauth2/callback/github）</label>
                    <input type="text" class="form-control" name="callback" id="callback" value="${githubControl.callback}">
                  </div>
                  <div class="form-group">
                    <label for="inactive">启用</label>
                    <select class="form-control" id="inactive" name="inactive" size="1">
                      <option value="F" ${ga:selected($githubControl.opened, "F")}>否</option>
                      <option value="T" ${ga:selected($githubControl.opened, "T")}>是</option>
                    </select>
                  </div>
                    <#
                     if ($isSuper == "T")
                     #>
                  <button id="letsgo" type="button" class="btn btn-primary">保存</button>
                    <#
                     else
                     #>
                  <button id="letsgo" type="button" class="btn btn-primary" disabled>保存</button>
                    <#
                     fi;
                     #>
                </form>
       
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<#
 include "js.html";
 #>
<script src="js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="js/lightyear.js"></script>
<script type="text/javascript">
$('#letsgo').on('click', function(){
    lightyear.loading('show');
    $.ajax({
        type: "POST",
        url: "/openapi/v1/oauth2/github/edit",
        contentType: "application/json;charset=utf-8",
        data:JSON.stringify({"clientId":$('#clientId').val(),"clientSecret":$('#clientSecret').val(),"callback":$('#callback').val(),"opened":$('#inactive').val()}),
        dataType: "json",
        success:function (message) {
            lightyear.loading('hide');
            if (message.sta == 0) {
            	$('#oldpwd').prop('disabled',false);
                lightyear.notify('修改成功', 'success', 1000);
            } else {
                lightyear.notify(message.msg, 'danger', 1000);
            }
        },
        error:function (message) {
            lightyear.loading('hide');
            lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
        }
    });
});
</script>
</body>
</html>